def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def closest_prime_number(words):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}

    num_str = ''
    for word in words:
        if word in numbers:
            num_str += str(numbers[word])
        else:
            return "Wrong input"

    num = int(num_str)

    for i in range(max(num - 1, 2), num + 2):
        if is_prime(i):
            return i

    return num

words = input().split()
result = closest_prime_number(words)
print(result)
